package tx.bjdacp.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import tx.bjdacp.model.*;
import tx.bjdacp.dao.*;
import tx.bjdacp.service.*;
import tx.bjdacp.vo.query.*;


@Entity
@Table(name = "bjdacp_gsp_info")
public class GspInfo extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;

	//alias
	public static final String TABLE_ALIAS = "GSP认证情况";
	public static final String ALIAS_GSP_INFO_ID = "gspInfoId";
	public static final String ALIAS_DRUG_SELL_UNIT_ID = "drugSellUnitId";
	public static final String ALIAS_ACCEPT_CODE = "受理号";
	public static final String ALIAS_ACCEPT_DATE = "受理时间";
	public static final String ALIAS_UNIT_NAME = "企业名称";
	public static final String ALIAS_CERT_TYPE = "认证类型";
	public static final String ALIAS_CERT_KIND = "认证性质";
	public static final String ALIAS_CERT_RESULT = "认证结果";
	public static final String ALIAS_CERT_BUG_ITEM = "认证缺陷项";
	public static final String ALIAS_GSP_CODE = "证号";
	public static final String ALIAS_GSP_GIVE_DATE = "发证时间";
	public static final String ALIAS_GSP_EXPIRY_DATE = "有效期";
	public static final String ALIAS_SEND_DATE = "送达时间";
	public static final String ALIAS_QUARTER = "所属季度";

	//date formats
	public static final String FORMAT_ACCEPT_DATE = DATE_FORMAT;
	public static final String FORMAT_GSP_GIVE_DATE = DATE_FORMAT;
	public static final String FORMAT_GSP_EXPIRY_DATE = DATE_FORMAT;
	public static final String FORMAT_SEND_DATE = DATE_FORMAT;


	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * gspInfoId       db_column: gsp_info_id
     */
	
	private java.lang.Integer gspInfoId;
    /**
     * drugSellUnitId       db_column: drug_sell_unit_id
     */
	
	private java.lang.Integer drugSellUnitId;
    /**
     * 受理号       db_column: accept_code
     */
	@Length(max=100)
	private java.lang.String acceptCode;
    /**
     * 受理时间       db_column: accept_date
     */
	
	private java.util.Date acceptDate;
    /**
     * 企业名称       db_column: unit_name
     */
	@Length(max=100)
	private java.lang.String unitName;
    /**
     * 认证类型       db_column: cert_type
     */
	@Length(max=100)
	private java.lang.String certType;
    /**
     * 认证性质       db_column: cert_kind
     */
	@Length(max=100)
	private java.lang.String certKind;
    /**
     * 认证结果       db_column: cert_result
     */
	@Length(max=100)
	private java.lang.String certResult;
    /**
     * 认证缺陷项       db_column: cert_bug_item
     */
	@Length(max=100)
	private java.lang.String certBugItem;
    /**
     * 证号       db_column: gsp_code
     */
	@Length(max=100)
	private java.lang.String gspCode;
    /**
     * 发证时间       db_column: gsp_give_date
     */
	
	private java.util.Date gspGiveDate;
    /**
     * 有效期       db_column: gsp_expiry_date
     */
	
	private java.util.Date gspExpiryDate;
    /**
     * 送达时间       db_column: send_date
     */
	
	private java.util.Date sendDate;
    /**
     * 所属季度       db_column: quarter
     */
	@Length(max=100)
	private java.lang.String quarter;
	//columns END


	public GspInfo(){
	}

	public GspInfo(
		java.lang.Integer gspInfoId
	){
		this.gspInfoId = gspInfoId;
	}



	public void setGspInfoId(java.lang.Integer value) {
		this.gspInfoId = value;
	}

	@Id	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "gsp_info_id", unique = true, nullable = false, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getGspInfoId() {
		return this.gspInfoId;
	}

	@Column(name = "drug_sell_unit_id", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getDrugSellUnitId() {
		return this.drugSellUnitId;
	}

	public void setDrugSellUnitId(java.lang.Integer value) {
		this.drugSellUnitId = value;
	}

	@Column(name = "accept_code", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getAcceptCode() {
		return this.acceptCode;
	}

	public void setAcceptCode(java.lang.String value) {
		this.acceptCode = value;
	}

	@Transient
	public String getAcceptDateString() {
		return DateConvertUtils.format(getAcceptDate(), FORMAT_ACCEPT_DATE);
	}
	public void setAcceptDateString(String value) {
		setAcceptDate(DateConvertUtils.parse(value, FORMAT_ACCEPT_DATE,java.util.Date.class));
	}

	@Column(name = "accept_date", unique = false, nullable = true, insertable = true, updatable = true, length = 23)
	public java.util.Date getAcceptDate() {
		return this.acceptDate;
	}

	public void setAcceptDate(java.util.Date value) {
		this.acceptDate = value;
	}

	@Column(name = "unit_name", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getUnitName() {
		return this.unitName;
	}

	public void setUnitName(java.lang.String value) {
		this.unitName = value;
	}

	@Column(name = "cert_type", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getCertType() {
		return this.certType;
	}

	public void setCertType(java.lang.String value) {
		this.certType = value;
	}

	@Column(name = "cert_kind", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getCertKind() {
		return this.certKind;
	}

	public void setCertKind(java.lang.String value) {
		this.certKind = value;
	}

	@Column(name = "cert_result", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getCertResult() {
		return this.certResult;
	}

	public void setCertResult(java.lang.String value) {
		this.certResult = value;
	}

	@Column(name = "cert_bug_item", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getCertBugItem() {
		return this.certBugItem;
	}

	public void setCertBugItem(java.lang.String value) {
		this.certBugItem = value;
	}

	@Column(name = "gsp_code", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getGspCode() {
		return this.gspCode;
	}

	public void setGspCode(java.lang.String value) {
		this.gspCode = value;
	}

	@Transient
	public String getGspGiveDateString() {
		return DateConvertUtils.format(getGspGiveDate(), FORMAT_GSP_GIVE_DATE);
	}
	public void setGspGiveDateString(String value) {
		setGspGiveDate(DateConvertUtils.parse(value, FORMAT_GSP_GIVE_DATE,java.util.Date.class));
	}

	@Column(name = "gsp_give_date", unique = false, nullable = true, insertable = true, updatable = true, length = 23)
	public java.util.Date getGspGiveDate() {
		return this.gspGiveDate;
	}

	public void setGspGiveDate(java.util.Date value) {
		this.gspGiveDate = value;
	}

	@Transient
	public String getGspExpiryDateString() {
		return DateConvertUtils.format(getGspExpiryDate(), FORMAT_GSP_EXPIRY_DATE);
	}
	public void setGspExpiryDateString(String value) {
		setGspExpiryDate(DateConvertUtils.parse(value, FORMAT_GSP_EXPIRY_DATE,java.util.Date.class));
	}

	@Column(name = "gsp_expiry_date", unique = false, nullable = true, insertable = true, updatable = true, length = 23)
	public java.util.Date getGspExpiryDate() {
		return this.gspExpiryDate;
	}

	public void setGspExpiryDate(java.util.Date value) {
		this.gspExpiryDate = value;
	}

	@Transient
	public String getSendDateString() {
		return DateConvertUtils.format(getSendDate(), FORMAT_SEND_DATE);
	}
	public void setSendDateString(String value) {
		setSendDate(DateConvertUtils.parse(value, FORMAT_SEND_DATE,java.util.Date.class));
	}

	@Column(name = "send_date", unique = false, nullable = true, insertable = true, updatable = true, length = 23)
	public java.util.Date getSendDate() {
		return this.sendDate;
	}

	public void setSendDate(java.util.Date value) {
		this.sendDate = value;
	}

	@Column(name = "quarter", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getQuarter() {
		return this.quarter;
	}

	public void setQuarter(java.lang.String value) {
		this.quarter = value;
	}


	private DrugSellUnit drugSellUnit;
	public void setDrugSellUnit(DrugSellUnit drugSellUnit){
		this.drugSellUnit = drugSellUnit;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "drug_sell_unit_id",nullable = false, insertable = false, updatable = false) 
	})
	public DrugSellUnit getDrugSellUnit() {
		return drugSellUnit;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("GspInfoId",getGspInfoId())
			.append("DrugSellUnitId",getDrugSellUnitId())
			.append("AcceptCode",getAcceptCode())
			.append("AcceptDate",getAcceptDate())
			.append("UnitName",getUnitName())
			.append("CertType",getCertType())
			.append("CertKind",getCertKind())
			.append("CertResult",getCertResult())
			.append("CertBugItem",getCertBugItem())
			.append("GspCode",getGspCode())
			.append("GspGiveDate",getGspGiveDate())
			.append("GspExpiryDate",getGspExpiryDate())
			.append("SendDate",getSendDate())
			.append("Quarter",getQuarter())
			.toString();
	}

	public int hashCode() {
		return new HashCodeBuilder()
			.append(getGspInfoId())
			.toHashCode();
	}

	public boolean equals(Object obj) {
		if(obj instanceof GspInfo == false) return false;
		if(this == obj) return true;
		GspInfo other = (GspInfo)obj;
		return new EqualsBuilder()
			.append(getGspInfoId(),other.getGspInfoId())
			.isEquals();
	}
}

